package cn.kgc.service;

import cn.kgc.mapper.CompanyMapper;
import cn.kgc.pojo.Auditstate;

import java.io.Serializable;
import java.util.List;


import javax.annotation.Resource;

import cn.kgc.pojo.Company;
import cn.kgc.util.Page;
import com.alibaba.dubbo.config.annotation.Service;


/**
* 描述： 服务实现层接口
* @author 
* @date 2018/03/05
*/
@Service
public class CompanyServiceImpl implements CompanyService{
	@Resource
	private CompanyMapper companyMapper;

 	/**
    * 描述：根据Id获取Company对象
     * @param id
     */
    public Company findById(Serializable id){
    	return companyMapper.findById(id);
    }
    /**
    * 描述：获取所有的Company对象
    */
    public List<Company> findAll(){
    	return companyMapper.findAll();
    }

	/**
    * 描述：新增保存Company对象
    */
    public int save(Company company){
    	return  companyMapper.save(company);
    }

    @Override
    public List<Auditstate> selectAllAuditstate() {
        return companyMapper.selectAllAuditstate();
    }

    /**
    * 描述：根据Id删除Company对象
    * @param id
    */
    public int delete(Serializable id){
    	return  companyMapper.delete(id);
    }
	
	/**
    * 描述：更新Company对象
    */
    public int update(Integer companyId,Integer auditState){
    	return  companyMapper.update(companyId,auditState);
    }

    @Override
    public String seleceEmail(Integer companyId) {
        return companyMapper.seleceEmail(companyId);
    }

    /**
     * 根据不确定的条件，动态查询
     */
    public List<Company> query(Object params){
    	return  companyMapper.query(params);
    }

    /**
     * 根据不确定的条件，动态分页查询
     */
    public Page queryByPage(String companyName, Integer index, Integer size){
         Page page=new Page();
        page.setPageIndex(index);
        page.setSize(size);
        page.setTotalCount(companyMapper.getCount(companyName));
        page.setList(companyMapper.queryByPage(companyName,index,size));
        return page;
    }

	@Override
	public int getCount(String companyName) {
		return companyMapper.getCount(companyName);
	}

}
